<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ project_name }} - 测试报告</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .header {
            text-align: center;
            margin-bottom: 30px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 5px;
        }
        
        .summary {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .summary-item {
            padding: 15px;
            border-radius: 5px;
            text-align: center;
        }
        
        .total { background-color: #e9ecef; }
        .passed { background-color: #d4edda; }
        .failed { background-color: #f8d7da; }
        .error { background-color: #f8d7da; }
        .skipped { background-color: #fff3cd; }
        
        .details {
            margin-top: 30px;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        
        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #dee2e6;
        }
        
        th {
            background-color: #f8f9fa;
        }
        
        tr:nth-child(even) {
            background-color: #f8f9fa;
        }
        
        .result-pass { color: #28a745; }
        .result-fail { color: #dc3545; }
        .result-error { color: #dc3545; }
        .result-skip { color: #ffc107; }
        
        .request-response {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 5px;
            margin-top: 10px;
            white-space: pre-wrap;
            font-family: monospace;
        }
        
        .error-message {
            color: #dc3545;
            margin-top: 10px;
            padding: 10px;
            background-color: #f8d7da;
            border-radius: 5px;
        }
        
        .footer {
            margin-top: 30px;
            text-align: center;
            color: #6c757d;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>{{ project_name }} - 测试报告</h1>
        <p>
            执行时间：{{ start_time }} 至 {{ end_time }}<br>
            总耗时：{{ duration|floatformat:2 }} 秒
        </p>
    </div>

    <div class="summary">
        <div class="summary-item total">
            <h3>总用例数</h3>
            <p>{{ summary.total_cases }}</p>
        </div>
        <div class="summary-item passed">
            <h3>通过数</h3>
            <p>{{ summary.passed_cases }}</p>
        </div>
        <div class="summary-item failed">
            <h3>失败数</h3>
            <p>{{ summary.failed_cases }}</p>
        </div>
        <div class="summary-item error">
            <h3>错误数</h3>
            <p>{{ summary.error_cases }}</p>
        </div>
        <div class="summary-item skipped">
            <h3>跳过数</h3>
            <p>{{ summary.skipped_cases }}</p>
        </div>
        <div class="summary-item total">
            <h3>通过率</h3>
            <p>{{ summary.pass_rate }}</p>
        </div>
    </div>

    <div class="details">
        <h2>执行详情</h2>
        <table>
            <thead>
                <tr>
                    <th>用例名称</th>
                    <th>接口</th>
                    <th>状态</th>
                    <th>结果</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>耗时(秒)</th>
                </tr>
            </thead>
            <tbody>
                {% for detail in execution_details %}
                <tr>
                    <td>{{ detail.case_name }}</td>
                    <td>{{ detail.interface }}</td>
                    <td>{{ detail.status }}</td>
                    <td class="result-{{ detail.result }}">{{ detail.result }}</td>
                    <td>{{ detail.start_time }}</td>
                    <td>{{ detail.end_time }}</td>
                    <td>{{ detail.duration|floatformat:2 }}</td>
                </tr>
                {% if detail.error_message %}
                <tr>
                    <td colspan="7">
                        <div class="error-message">
                            {{ detail.error_message }}
                        </div>
                    </td>
                </tr>
                {% endif %}
                <tr>
                    <td colspan="7">
                        <div class="request-response">
                            <strong>请求数据：</strong>
                            <pre>{{ detail.request_data|pprint }}</pre>
                            <strong>响应数据：</strong>
                            <pre>{{ detail.response_data|pprint }}</pre>
                        </div>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    <div class="footer">
        <p>报告生成时间：{{ generated_time }}</p>
    </div>
</body>
</html> 